package com.ygsoft.activiti.model;

import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.task.Comment;
import org.apache.commons.lang.StringUtils;

import java.util.Date;

/**
 * 用户Dao
 *
 * @author zhx
 * @create 2017-11-08 14:21
 **/
public class MyHistoricProc {
    //任务ID
    private String hisProcId = "";
    //任务名称
    private String hisProcName ="";
    //任务开始时间
    private Date hisProcStartTime;
    //任务结束时间
    private Date hisProcEndTime;
    //任务处理人的Id
    private String hisProcUserId="";
    //处理任务人的名称
    private String hisProcUserName ="";
    //批注
    private String comment="";
    //状态
    private String status="";

    public MyHistoricProc(){

    }

    public MyHistoricProc(HistoricActivityInstance historicTaskInstance){
        this.hisProcId = historicTaskInstance.getProcessInstanceId();
        this.hisProcStartTime = historicTaskInstance.getStartTime();
        this.hisProcEndTime = historicTaskInstance.getEndTime();
        //开始事件
        if(historicTaskInstance.getActivityType().equals("startEvent")){
            this.hisProcName = "提交申请";
        }else if(historicTaskInstance.getActivityType().equals("endEvent")){
            this.hisProcName = "审批结束";
        }else{
            this.hisProcName = historicTaskInstance.getActivityName();
        }
    }

    public MyHistoricProc setComment(HistoricTaskInstance historicTaskInstance, Comment comment){
        this.hisProcUserId = comment.getUserId();
        this.comment = comment.getFullMessage();

        if(historicTaskInstance.getDeleteReason().equals("completed")){
            this.status = "通过!";
        }else if(StringUtils.isEmpty(historicTaskInstance.getDeleteReason())){
            this.status = "未处理!";
        }

        return this;
    }

    public String getHisProcUserName() {
        return hisProcUserName;
    }

    public void setHisProcUserName(String hisProcUserName) {
        this.hisProcUserName = hisProcUserName;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getHisProcUserId() {
        return hisProcUserId;
    }

    public void setHisProcUserId(String hisProcUserId) {
        this.hisProcUserId = hisProcUserId;
    }

    public Date getHisProcStartTime() {
        return hisProcStartTime;
    }

    public void setHisProcStartTime(Date hisProcStartTime) {
        this.hisProcStartTime = hisProcStartTime;
    }

    public Date getHisProcEndTime() {
        return hisProcEndTime;
    }

    public void setHisProcEndTime(Date hisProcEndTime) {
        this.hisProcEndTime = hisProcEndTime;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getHisProcId() {
        return hisProcId;
    }

    public void setHisProcId(String hisProcId) {
        this.hisProcId = hisProcId;
    }

    public String getHisProcName() {
        return hisProcName;
    }

    public void setHisProcName(String hisProcName) {
        this.hisProcName = hisProcName;
    }
}
